package cn.iocoder.yudao.module.search.controller.app.search;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.search.api.search.dto.SearchQueryReqDTO;
import cn.iocoder.yudao.module.search.api.search.dto.SearchQueryRespDTO;
import cn.iocoder.yudao.module.search.service.search.SearchService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 用户端 - 搜索管理
 *
 * @author 芋道源码
 */
@Tag(name = "用户端 - 搜索管理")
@RestController
@RequestMapping("/app-api/search")
@RequiredArgsConstructor
@Validated
public class AppSearchController {

    private final SearchService searchService;

    @PostMapping("/query")
    @Operation(summary = "搜索查询")
    public CommonResult<SearchQueryRespDTO> search(@Valid @RequestBody SearchQueryReqDTO reqDTO) {
        SearchQueryRespDTO result = searchService.search(reqDTO);
        return success(result);
    }

}
